<template>
  <div>
    <van-nav-bar
      title="我的钱包"
      left-arrow
      @click-left="onClickLeft"
    />
    <div style="text-align:center">
      <p style="font-size:60px;margin:5px">
        <van-icon
          name="gold-coin"
          color="orange"
        />
      </p>
      <p style="margin:3px">我的零钱</p>
      <p style="font-size:30px;margin:5px">￥{{account.balance}}</p>
    </div>
    <div class="chongzhi_box">
      <van-button
        type="primary"
        class="chongzhi btn"
      >充值</van-button>
    </div>
    <div class="tixian_box">
      <van-button class="tixian btn">提现</van-button>
    </div>
  </div>
</template>

<script>
export default {
  name: "account",
  data() {
    return {
      account: {},
    };
  },
  methods: {
    onClickLeft() {
      window.history.go(-1);
    },
    getaccount() {
      this.axios
        .post("apis/kuan_api/account.php", {
          code: 0,
          userid: this.$store.state.user.user_id,
        })
        .then((res) => {
          if (res.data.errorCode == 1) {
            this.account = res.data.data[0];
          } else {
            this.getaccount();
          }
        })
        .catch((err) => {
          console.error(err);
        });
    },
  },
  created() {
    this.getaccount();
  },
};
</script>

<style scoped>
.btn {
  width: 150px;
  border-radius: 5px;
}
.chongzhi_box {
  position: fixed;
  bottom: 155px;
  left: 0;
  width: 100%;
  text-align: center;
}
.tixian_box {
  position: fixed;
  bottom: 95px;
  left: 0;
  width: 100%;
  text-align: center;
}
</style>